// pages/changepassword/changepassword.js
import { request } from "../../utils/https";
Page({

  /**
   * 页面的初始数据
   */
  data: {
    newpassword:[],
    anpassword:[],
    code:[]
  },codenth(){
    let _self=this;
    console.log(1)
    request(
      "register/verify",
      {
        "phone": wx.getStorageSync('phone')
      },'POST',
      function(res) {
        console.log(res)
        wx.showToast({
          title: res.data.msg,
          icon:"none"
        })
      }
    )
  },save(){
    let _self=this;
    request(
      'register/reset',
      {"account": wx.getStorageSync('phone'), captcha: _self.data.code, password: _self.data.anpassword},
      'POST',
      function(res){
        console.log(res.data.msg)
        wx.removeStorageSync('token')
        wx.redirectTo({
          url: '/pages/wode/wode',
        })
      }
    )
  }
  ,newpassword(e){
    let _self=this;
    console.log(e.detail.value)
    _self.data.newpassword=e.detail.value
    _self.setData({
      newpassword:_self.data.newpassword
    })
    console.log(_self.data.newpassword)
  },anpassword(e){
    let _self=this;
    console.log(e.detail.value)
    _self.data.anpassword=e.detail.value
    _self.setData({
      anpassword:_self.data.anpassword
    })
    console.log(_self.data.anpassword)
  },code(e){
    let _self=this;
    console.log(e.detail.value)
    _self.data.code=e.detail.value
    _self.setData({
      code:_self.data.code
    })
    console.log(_self.data.code)
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})